﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartMathLibrary.Interfaces.Web.Twitter
{
    /// <summary>
    /// This class represents a twitter timeline.
    /// </summary>
    [Serializable]
    public class TimelineItem : ITimelineItem
    {
        /// <summary>
        /// The user information of the timeline item.
        /// </summary>
        private User user;

        /// <summary>
        /// The status information of the timeline item.
        /// </summary>
        private Status status;

        /// <summary>
        /// Initializes a new instance of the <see cref="TimelineItem"/> class.
        /// </summary>
        public TimelineItem()
        {
            this.user = new User();
            this.status = new Status();
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="TimelineItem"/> class.
        /// </summary>
        /// <param name="user">The user information of the timeline item.</param>
        /// <param name="status">The status information of the timeline item.</param>
        public TimelineItem(User user, Status status)
        {
            if (user == (User) null)
            {
                throw new ArgumentNullException("user");
            }

            if (status == (Status) null)
            {
                throw new ArgumentNullException("status");
            }

            this.user = user;
            this.status = status;
        }

        /// <summary>
        /// Gets or sets the user information of the timeline item.
        /// </summary>
        /// <value>The user information of the timeline item.</value>
        public User User
        {
            get { return user; }
            set { user = value; }
        }

        /// <summary>
        /// Gets or sets the status information of the timeline item.
        /// </summary>
        /// <value>The status information of the timeline item.</value>
        public Status Status
        {
            get { return status; }
            set { status = value; }
        }

        /// <summary>
        /// Compares the current user instance to another one.
        /// </summary>
        /// <param name="compare">The instance to compare.</param>
        /// <returns>True if the values of the current instance and the specified instance are equal otherwise, false.</returns>
        public bool CompareTo(TimelineItem compare)
        {
            return ((this.user == compare.User) && (this.status == compare.Status));
        }

        /// <summary>
        /// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <param name="obj">The <see cref="T:System.Object"/> to compare with the current <see cref="T:System.Object"/>.</param>
        /// <returns>
        /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
        /// </returns>
        /// <exception cref="T:System.NullReferenceException">The <paramref name="obj"/> parameter is null.</exception>
        public override bool Equals(object obj)
        {
            return base.Equals(obj);
        }

        /// <summary>
        /// Serves as a hash function for a particular type.
        /// </summary>
        /// <returns>
        /// A hash code for the current <see cref="T:System.Object"/>.
        /// </returns>
        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        /// <summary>
        /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </returns>
        public override string ToString()
        {
            return "status={" + this.status.ToString() + "}" + "user={" + this.user.ToString() + "}";
        }
    }
}